<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<meta name="viewport"
	content="width=device-width, maximum-scale=1.0, initial-scale=1.0,initial-scale=1.0,user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<title><#if systemConfig?? && systemConfig.title?? && systemConfig.title != ''>${systemConfig.title}<#else>UCKeFu-全渠道客服系统</#if></title>
<link rel="shortcut icon" type="image/x-icon" href="<#if systemConfig?? && systemConfig.favlogo?? && systemConfig.favlogo != ''>/res/image.html?id=${systemConfig.favlogo?url}<#else>/images/favicon.ico?v=ukefu</#if>&t=${.now?long}"/>
<link rel="stylesheet" href="/css/layui.css">
<link rel="stylesheet" href="/css/login.css">
<link rel="stylesheet" href="/css/flexboxgrid.min.css">
<script src="/layui.js"></script>
<script language="javascript">
	if((window.frameElement && window.frameElement.id || '') != ""){
		top.location.href = "/login.html" ;
	}
	layui.use('layer', function(){
	  var layer = layui.layer;
	  <#if msg?? && msg == '0'>
		layer.alert('账号或密码错误，请重新填写', {icon: 2});
	  <#elseif msg?? && msg == '1'>
		layer.alert('用户注册成功，请使用手机和密码登录', {icon: 1});
	  <#elseif msg?? && msg == '10'>
		layer.alert('用户名、密码或验证码错误', {icon: 2});
	<#elseif msg?? && msg == '11'>
		layer.alert('租户被锁定或删除或不存在', {icon: 2});
	</#if>
	});   
	layui.use('form', function(){
		var form = layui.form;
	});
	/**
	 * Get the user IP throught the webkitRTCPeerConnection
	 * @param onNewIP {Function} listener function to expose the IP locally
	 * @return undefined
	 */
	function getUserIP(onNewIP) { //  onNewIp - your listener function for new IPs
	    //compatibility for firefox and chrome
	    var myPeerConnection = window.RTCPeerConnection || window.mozRTCPeerConnection || window.webkitRTCPeerConnection;
	    var pc = new myPeerConnection({
	        iceServers: []
	    }),
	    noop = function() {},
	    localIPs = {},
	    ipRegex = /([0-9]{1,3}(\.[0-9]{1,3}){3}|[a-f0-9]{1,4}(:[a-f0-9]{1,4}){7})/g,
	    key;

	    function iterateIP(ip) {
	        if (!localIPs[ip]) onNewIP(ip);
	        localIPs[ip] = true;
	    }

	     //create a bogus data channel
	    pc.createDataChannel("");

	    // create offer and set local description
	    pc.createOffer().then(function(sdp) {
	        sdp.sdp.split('\n').forEach(function(line) {
	            if (line.indexOf('candidate') < 0) return;
	            line.match(ipRegex).forEach(iterateIP);
	        });
	        
	        pc.setLocalDescription(sdp, noop, noop);
	    }).catch(function(reason) {
	        // An error occurred, so handle the failure to connect
	    });

	    //listen for candidate events
	    pc.onicecandidate = function(ice) {
	        if (!ice || !ice.candidate || !ice.candidate.candidate || !ice.candidate.candidate.match(ipRegex)) return;
	        ice.candidate.candidate.match(ipRegex).forEach(iterateIP);
	    };
	}
</script>
</head>

<body class="login">
	<div class="login-box">
	
		
		<div class="login-logo">
			<a> <img src="<#if systemConfig?? && systemConfig.loginlogo?? && systemConfig.loginlogo != ''>/res/image.html?id=${systemConfig.loginlogo?url}<#else>images/logo2.png</#if>" style="max-width:<#if systemConfig.loginlogowidth??>${systemConfig.loginlogowidth}<#else>220</#if>px;max-height:<#if systemConfig.loginlogoheight??>${systemConfig.loginlogoheight}<#else>80</#if>px;">
			</a>
		</div>
		<div class="login-box-body">

			<p class="login-box-msg">账号密码登录</p>
			<form id="loginForm" action="/login.html"class="layui-form" method="post">
				<input type="hidden" name="clientip" id="clientip"/> 
				<div class="form-group has-feedback">
					<span class="layui-icon form-control-feedback">&#xe612;</span> 
					<!-- <input name="username" id="username" autofocus required lay-verify="required"  
						class="form-control required" value="" placeholder="用户名/邮件/手机号"> -->
						<input name="username" id="username" autofocus required lay-verify="required"  
						class="form-control required" value="" placeholder="登录账号">
				</div>
				<div class="form-group has-feedback" style="margin-bottom:10px;">
					<span class="layui-icon form-control-feedback">&#xe673;</span>
					<!-- <input type="password" name="password" required lay-verify="required"  
						class="form-control required" value="" placeholder="密码"> -->
					<input type="password" name="password" id="password" required lay-verify="required"  
						class="form-control required" value="" placeholder="密码">
				</div>
				<#if systemConfig?? && systemConfig.vcode == true>
				<div class="form-group has-feedback" style="margin-bottom:10px;">
					<span class="layui-icon form-control-feedback">&#xe679;</span>
					<!-- <input type="password" name="password" required lay-verify="required"  
						class="form-control required" value="" placeholder="密码"> -->
					<input type="text" name="code" id="code" required lay-verify="required" style="width:160px;"  
						class="form-control required" value="" placeholder="请输入验证码">
					<span class="layui-icon form-control-code"><img id="code_img" style="cursor: pointer;"  src="/code.html" onclick="document.getElementById('code_img').src = '/code.html?t='+new Date().getTime()"></span>
				</div>
				</#if>
				<#if systemConfig?? && systemConfig.remember == true>
				<div class="row" style="line-height:30px;padding:0 20px;">
					<div class="col-lg-6">
						<div class="checkbox">
							<input type="checkbox" name="sla" value="1" lay-skin="primary" checked title="七天内自动登录">
						</div>
					</div>
				</div>
				</#if>
				<div class="row" style="margin-bottom:20px;padding:0 20px;">
					<div class="col-md-6"></div>
				</div>
				<div class="row" style="margin-bottom:20px;padding:0 20px;">

					<!-- /.col -->
					<div class="col-xs-12">
						<button class="btn btn-block btn-primary btn-lg">立即登录</button>
					</div>
				</div>
			</form>
		</div>
		<!-- /.login-box-body -->
	</div>
</body>
<script language="javascript">
	getUserIP(function(ip){
		document.getElementById('clientip').value = ip ;
	});
</script>
</html>